package com.tripwego.server.jdo;

import java.io.Serializable;
import java.util.Date;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.tripwego.client.model.TripModel;

@PersistenceCapable
public class TripJDO implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Long id;
	@Persistent
	private String name;

	// foreign key
	@Persistent
	private Long userId;
	@Persistent
	private Long categoryId;

	private Date dateCreation;
	@Persistent
	private Date dateModification;
	@Persistent
	private String statut;

	/**
	 * 
	 */
	public TripJDO() {
		super();
	}

	public void initDataFromModel(TripModel model) {

		setCategoryId(model.getCategoryId());
		setDateCreation(model.getDateCreation());
		setDateModification(model.getDateModification());
		
		setName(model.getName());
		setStatut(model.getStatut());
		setUserId(model.getUserId());
	}

	public static TripModel entityToModel(TripJDO entity) {

		TripModel model = new TripModel();
		
		model.setCategoryId(entity.getCategoryId());
		model.setDateCreation(entity.getDateCreation());
		model.setDateModification(entity.getDateModification());
		model.setId(entity.getId());
		model.setName(entity.getName());
		model.setStatut(entity.getStatut());
		model.setUserId(entity.getUserId());
		
		return model;
	}

	/**
	 * @return the id
	 */
	public Long getId() {
		return id;
	}

	/**
	 * @param id the id to set
	 */
	public void setId(Long id) {
		this.id = id;
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @return the userId
	 */
	public Long getUserId() {
		return userId;
	}

	/**
	 * @param userId the userId to set
	 */
	public void setUserId(Long userId) {
		this.userId = userId;
	}

	/**
	 * @return the categoryId
	 */
	public Long getCategoryId() {
		return categoryId;
	}

	/**
	 * @param categoryId the categoryId to set
	 */
	public void setCategoryId(Long categoryId) {
		this.categoryId = categoryId;
	}

	/**
	 * @return the dateCreation
	 */
	public Date getDateCreation() {
		return dateCreation;
	}

	/**
	 * @param dateCreation the dateCreation to set
	 */
	public void setDateCreation(Date dateCreation) {
		this.dateCreation = dateCreation;
	}

	/**
	 * @return the dateModification
	 */
	public Date getDateModification() {
		return dateModification;
	}

	/**
	 * @param dateModification the dateModification to set
	 */
	public void setDateModification(Date dateModification) {
		this.dateModification = dateModification;
	}

	/**
	 * @return the statut
	 */
	public String getStatut() {
		return statut;
	}

	/**
	 * @param statut the statut to set
	 */
	public void setStatut(String statut) {
		this.statut = statut;
	}

	
	

}